Ext.namespace("ChangeSystem");

Ext.define('HIT.view.DealSendSearchWin', {
    extend: 'Ext.window.Window',
    alias: 'widget.DealSendSearchWin',

    height: 250,
    width: 664,
    overlapHeader: false,
    preventHeader: false,
    title: Share.T('查询'),

    initComponent: function() {
        var me = this;
        this.title = Share.T('查询');        
        Ext.applyIf(me, {
            items: [
                {
                            xtype: 'panel',
                            layout: {
                                type: 'absolute'
                            },
                            height: 250,
                            items: [//单据号
                                    {
                                    	xtype : 'combobox',
                                    	x: 20,
                                        y: 30,
                                        labelWidth: 60,
                                        width: 180,
                        				triggerAction : 'query',
                        				editable : true,
                        				queryParam : 'code',//向后台传递输入框中的值
                        				minChars : 1,
                        				fieldLabel: Share.T('单据号'),
                        				emptyText : Share.T('请输入查询条件...'),
                         				id:'send_search_sno',
                        				valueField : 'value',
                        				displayField : 'value',
                        				hideTrigger : true, //隐藏下拉箭头  
                        				typeAhead : false,
                        				queryDelay : 700,
                        				queryMode : 'remote',
                        				store: new Ext.data.JsonStore({
                        					proxy: {
                            	                type: 'ajax', 
                            	                url : ctx + '/getDocNo',
                            	                reader : {
                            	                    type : 'json',
                            	                    totalProperty : '',
                            	                    root : '' 
                            	                } 
                        					},
                    	        	        fields : ['value','value'], 
                    	        	        autoLoad : true 
                    					}),
                        				listeners : {
                        					beforequery : function(e) {
            	            					var combo = e.combo;   
            	            					if(!e.forceAll){   
            	            						var value = e.query;   
            	            						combo.store.filterBy(function(record,id){   
            	            							var text = record.get(combo.displayField); 
            	            							return (text.indexOf(value)!=-1);   
            	            						});
            	            						combo.expand();   
            	            						return false;   
            	            					}
                        					}
                        				}
                                 },
                                {
                                	xtype : 'combobox',
                                	x: 205,
                                    y: 30,
                                    labelWidth: 15,
                                    width: 145,
                    				triggerAction : 'query',
                    				editable : true,
                    				queryParam : 'code',//向后台传递输入框中的值
                    				minChars : 1,
                    				fieldLabel: '~',
                     				labelSeparator: ' ',
                    				emptyText : Share.T('请输入查询条件...'),
                    				selectOnFocus : true,
                    				id:'send_search_eno',
                    				valueField : 'value',
                    				displayField : 'value',
                    				hideTrigger : true, //隐藏下拉箭头  
                    				typeAhead : false,
                    				queryDelay : 700,
                    				queryMode : 'remote',
                    				store: new Ext.data.JsonStore({
                    					proxy: {
                        	                type: 'ajax', 
                        	                url : ctx + '/getDocNo',
                        	                reader : {
                        	                    type : 'json',
                        	                    totalProperty : '',
                        	                    root : '' 
                        	                } 
                    					},
                	        	        fields : ['value','value'], 
                	        	        autoLoad : true 
                					}),
                    				listeners : {
                    					beforequery : function(e) {
        	            					var combo = e.combo;   
        	            					if(!e.forceAll){   
        	            						var value = e.query;   
        	            						combo.store.filterBy(function(record,id){   
        	            							var text = record.get(combo.displayField); 
        	            							return (text.indexOf(value)!=-1);   
        	            						});
        	            						combo.expand();   
        	            						return false;   
        	            					}
                    					}
                    				}
                                },
                                {
                                	xtype : 'combobox',
                                	x: 385,
                                    y: 30,
                                    width: 225,
                    				triggerAction : 'query',
                    				editable : true,
                    				minChars : 1,
                    				fieldLabel: '',
                    				multiSelect:true,
                    				emptyText : Share.T('请输入查询条件...'),
                    	 			id:'send_search_nos',
                    				valueField : 'value',
                    				displayField : 'value',
                    				hideTrigger : true, //隐藏下拉箭头  
                    				typeAhead : false,
                    				queryDelay : 700,
                    				queryMode : 'remote',
                    				store: new Ext.data.JsonStore({
                    					proxy: {
                        	                type: 'ajax', 
                        	                url : ctx + '/getDocNo',
                        	                reader : {
                        	                    type : 'json',
                        	                    totalProperty : '',
                        	                    root : '' 
                        	                } 
                    					},
                	        	        fields : ['value','value'], 
                	        	        autoLoad : true 
                					}),
                    				multiSelect:true,
                    				listeners : {
                    					beforequery : function(e) {
        	            					var combo = e.combo;
        	            					if(!e.forceAll){   
        	            						var value = e.query;  
        	            						var arr = value.split(",");
        	            						var val = arr[arr.length-1];
        	            						combo.store.filterBy(function(record,id){   
        	            							var text = record.get(combo.displayField); 
        	            							return (text.indexOf(val)!=-1);   
        	            						});
        	            						combo.expand();   
        	            						return false;   
        	            					}
                    					}
                    				}
                                },
                                //快递单号
                                {
                                	xtype : 'combobox',
                                	x: 20,
                                    y: 65,
                                    labelWidth: 60,
                                    width: 180,
                    				triggerAction : 'query',
                    				editable : true,
                    				minChars : 1,
                    				fieldLabel: Share.T('快递单号'),
                    				emptyText : Share.T('请输入查询条件...'),
                     		 		id:'send_search_sexpressno',
                    				valueField : 'value',
                    				displayField : 'value',
                    				hideTrigger : true, //隐藏下拉箭头  
                    				typeAhead : false,
                    				queryDelay : 700,
                    				queryMode : 'remote',
                    				store: new Ext.data.JsonStore({
                    					proxy: {
                        	                type: 'ajax', 
                        	                url : ctx + '/getDealSendExpressNo',
                        	                reader : {
                        	                    type : 'json',
                        	                    totalProperty : '',
                        	                    root : '' 
                        	                } 
                    					},
                	        	        fields : ['value','value'], 
                	        	        autoLoad : true 
                					}),
                    				listeners : {
                    					beforequery : function(e) {
        	            					var combo = e.combo;   
        	            					if(!e.forceAll){   
        	            						var value = e.query;   
        	            						combo.store.filterBy(function(record,id){   
        	            							var text = record.get(combo.displayField); 
        	            							return (text.indexOf(value)!=-1);   
        	            						});
        	            						combo.expand();   
        	            						return false;   
        	            					}
                    					}
                    				}
                             },
                            {
                            	xtype : 'combobox',
                            	x: 205,
                                y: 65,
                                labelWidth: 15,
                                width: 145,
                				triggerAction : 'query',
                				editable : true,
                				minChars : 1,
                				fieldLabel: '~',
                 				labelSeparator: ' ',
                				emptyText : Share.T('请输入查询条件...'),
                				selectOnFocus : true,
                	 			id:'send_search_eexpressno',
                				valueField : 'value',
                				displayField : 'value',
                				hideTrigger : true, //隐藏下拉箭头  
                				typeAhead : false,
                				queryDelay : 700,
                				queryMode : 'remote',
                				store: new Ext.data.JsonStore({
                					proxy: {
                    	                type: 'ajax', 
                    	                url : ctx + '/getDealSendExpressNo',
                    	                reader : {
                    	                    type : 'json',
                    	                    totalProperty : '',
                    	                    root : '' 
                    	                } 
                					},
            	        	        fields : ['value','value'], 
            	        	        autoLoad : true 
            					}),
                				listeners : {
                					beforequery : function(e) {
    	            					var combo = e.combo;   
    	            					if(!e.forceAll){   
    	            						var value = e.query;   
    	            						combo.store.filterBy(function(record,id){   
    	            							var text = record.get(combo.displayField); 
    	            							return (text.indexOf(value)!=-1);   
    	            						});
    	            						combo.expand();   
    	            						return false;   
    	            					}
                					}
                				}
                            },
                                //日期
                                {
                                    xtype: 'datefield',
                                    x: 20,
                                    y: 100,
                                    labelWidth:60,
                                    width: 180,
                                    fieldLabel: Share.T('发票日期'),
                                    id:'send_search_sday',
                                    editable : false,
                                    format		 : 'Y-m-d',
                                    msgTarget    : 'side'
                                },
                                {
                                    xtype: 'datefield',
                                    x: 205,
                                    y: 100,
                                    labelWidth: 15,
                                    width: 145,
                                    id:'send_search_eday',
                                    fieldLabel: '~',
                                    labelSeparator: ' ',
                                    editable : false,
                                    format:'Y-m-d',
                                    msgTarget    : 'side'
                                },
                                //客户名称
                                {
                                	xtype : 'combobox', 
                                	x: 20,
                                    y: 135,
                                    labelWidth: 60,
                                    width: 330,
                    				triggerAction : 'query',
                    				editable : true,
                    				queryParam : 'code',//向后台传递输入框中的值
                    				minChars : 1,
                    				fieldLabel : Share.T('客户名称'),
                    				emptyText : Share.T('请选择查询条件...'),
                    			 	id:'send_search_cust',
                    				valueField : 'value',
                    				displayField : 'value',
                    				hideTrigger : true, //隐藏下拉箭头  
                    				typeAhead : false,
                    				queryDelay : 700,
                    				queryMode : 'remote',
                    				store: new Ext.data.JsonStore({
                    					proxy: {
                        	                type: 'ajax', 
                        	                url : ctx + '/getDealSendCust',
                        	                reader : {
                        	                    type : 'json',
                        	                    totalProperty : '',
                        	                    root : '' 
                        	                } 
                    					},
                	        	        fields : ['value','value'], 
                	        	        autoLoad : true 
                					}),
                    				listeners : {
                    					beforequery : function(e) {
        	            					var combo = e.combo;   
        	            					if(!e.forceAll){   
        	            						var value = e.query;   
        	            						combo.store.filterBy(function(record,id){   
        	            							var text = record.get(combo.displayField); 
        	            							return (text.indexOf(value)!=-1);   
        	            						});
        	            						combo.expand();   
        	            						return false;   
        	            					}
                    					}
                    				}
                                }
                            ]
                }
            ],
            dockedItems: [
                {
                    xtype: 'toolbar',
                    dock: 'top',
                    items: [
                        {
                            xtype: 'button',
                            width: 65,
                            iconCls: 'tj-tree-file',
                            id  : 'send_search_button',
                            text: Share.T('查询')
                        },
                        {
                            xtype: 'tbfill'
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }

});
